<div layout="column">
    <div flex="15"></div>
    <div flex layout="row">
        <div flex="10" flex-gt-sm="30"></div>
        <div flex layout="column" layout-align="space-around stretch">
            <div style="height: 30px;"></div>
            <div style="width: 100%;" layout="row" layout-align="space-between center">
                <div flex="75" translate>从订单中选择类型</div>
                <div flex layout="row" layout-align="end center">
                    <md-switch ng-model="account.fromOrder" aria-label="fromOrder" ng-true-value="1" ng-false-value="0">
                    </md-switch>
                </div>
            </div>
            <form name="accountForm">
                <md-input-container class="md-block" ng-show="account.fromOrder === 0">
                    <label translate>类型</label>
                    <div layout="row">
                        <md-select ng-model="account.type" flex="75">
                            <md-option ng-repeat="type in typeList" value="{{type.value}}" translate>{{ type.key }}</md-option>
                        </md-select>
                        <div ng-if="+account.type >= 2 && +account.type <= 5" layout="row" layout-align="end center">
                            <md-button ng-click="pickTime()">
                                <md-icon class="material-icons">access_time</md-icon>
                            </md-button>
                        </div>
                    </div>
                </md-input-container>
                <md-input-container class="md-block" ng-show="+account.fromOrder === 1">
                    <label translate>类型</label>
                    <div layout="row">
                        <md-select ng-model="account.orderId" flex="75">
                            <md-option ng-repeat="order in orders" value="{{order.id}}" translate>{{ order.name }}</md-option>
                        </md-select>
                        <div layout="row" layout-align="end center">
                            <md-button ng-click="pickTime()">
                                <md-icon class="material-icons">access_time</md-icon>
                            </md-button>
                        </div>
                    </div>
                </md-input-container>
                <md-input-container class="md-block">
                    <label translate>端口</label>
                    <input type="number" required name="port" ng-model="account.port">
                    <div ng-messages="accountForm.port.$error">
                        <div ng-message="required">端口不能为空</div>
                    </div>
                </md-input-container>
                <md-input-container class="md-block">
                    <label translate>密码</label>
                    <input type="text" required name="password" ng-model="account.password">
                    <div ng-messages="accountForm.password.$error">
                        <div ng-message="required">密码不能为空</div>
                    </div>
                </md-input-container>
                <md-input-container class="md-block" ng-if="account.fromOrder === 1 || +account.type >= 1">
                    <label translate>流量</label>
                    <input type="text" required name="flow" ng-model="account.flowStr">
                    <div ng-messages="accountForm.flow.$error">
                        <div ng-message="required">流量不能为空</div>
                    </div>
                </md-input-container>
                <md-input-container class="md-block">
                    <label translate>自动删除延迟</label>
                    <input type="text" required name="autoRemoveDelay" ng-model="account.autoRemoveDelayStr" ng-disabled="!account.autoRemove">
                </md-input-container>
            </form>
            <div ng-if="account.fromOrder === 1 || +account.type >= 1" style="width: 100%; height: 52px;" layout="row" layout-align="space-between center" ng-click="setAccountServer()">
                <div flex="75" translate>
                    <span>自定义服务器&nbsp;[{{ account.server ? account.server.length : '∞' }}]</span>
                </div>
                <div flex layout="row" layout-align="end center">
                    <md-button class="md-icon-button"><md-icon>keyboard_arrow_right</md-icon></md-button>
                </div>
            </div>
            <div ng-if="account.fromOrder === 1 || +account.type >= 1" style="width: 100%;" layout="row" layout-align="space-between center">
                <div flex="75">合并多服务器流量统计</div>
                <div flex layout="row" layout-align="end center">
                    <md-switch ng-model="account.multiServerFlow" aria-label="multiServerFlow" ng-true-value="1" ng-false-value="0">
                    </md-switch>
                </div>
            </div>
            <div ng-if="account.fromOrder === 1 || +account.type !== 1" style="width: 100%;" layout="row" layout-align="space-between center">
                <div flex="75">到期自动删除</div>
                <div flex layout="row" layout-align="end center">
                    <md-switch ng-model="account.autoRemove" aria-label="autoRemove" ng-true-value="1" ng-false-value="0">
                    </md-switch>
                </div>
            </div>
            <md-autocomplete
                md-selected-item="accountUser.selectedItem"
                md-search-text-change="accountUser.searchChange(accountUser.search)"
                md-search-text="accountUser.search"
                md-selected-item-change="accountUser.selectedItemChange(item)"
                md-items="item in accountUser.querySearch(accountUser.search)"
                md-item-text="item.username"
                md-delay="750"
                md-require-match="true"
                md-autoselect="true"
                md-select-on-match="true"
                placeholder="指定用户(可选)"
            >
                <md-item-template>
                    <span md-highlight-text="accountUser.search" md-highlight-flags="i">{{ item.username }}</span>
                </md-item-template>
                <md-not-found>
                    没有匹配的用户
                </md-not-found>
            </md-autocomplete>
        </div>
        <div flex="10" flex-gt-sm="30"></div>
    </div>
    <div style="height: 50px;"></div>
    <div class="bottom-nav">
        <div flex layout="row" layout-align="center start">
            <div flex="10" flex-gt-sm="30"></div>
            <div layout="row" flex layout-align="space-around center">
                <md-button class="md-primary" ng-click="cancel()"><span transalte>取消</span></md-button>
                <md-button class="md-raised md-primary" ng-click="confirm()" ng-disabled="!account.password || !account.port || !account.flowStr"><span transalte>确认</span></md-button>
            </div>
            <div flex="10" flex-gt-sm="30"></div>
        </div>
    </div>
</div>
